- /* sdoplus.cpp by K.Tsuru */
- // function ID = 330 DRADIX
- /*********************************
- SDouble class
- It provides the addition operator+().
- It returns m+n.
- **********************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- SDouble operator+(const SDouble& m, const SDouble& n){
- if((m.Type() != m.REAL)||(n.Type() != n.REAL)) m.SetError(m.RADIX_ERR, "SD +", 330);
- int sgn = m.Sign(330) * n.Sign(330);
- if(sgn == 0){ //m=0 or n=0
- if( m.Sign() == 0 ) return n;
- else return m;
- } else if (sgn > 0){ //same sign
- return DDAdd(m, n);
- } else { //different sign
- int c = DDCompare(m, n);
- // m + n = m -(-n) = n-(-m)
- if(c > 0) return DDSub(m, -n); //|m|>|n|, The sign is the same as that of m, set in DDSub()
- else if(c) return DDSub(n, -m); //|m|<|n|, sign same as n
- else return 0.0; // c = 0 : m = n result = 0
- }
- }
sdoplus.cpp : last modifiled at 2015/11/25 20:18:04(897 bytes)
created at 2017/10/07 10:21:14
The creation time of this html file is 2017/10/07 10:30:03 (Sat Oct 07 10:30:03 2017).